package com.jubao.modules.sys.service.impl;

import com.jubao.common.entity.Page;
import com.jubao.common.entity.Query;
import com.jubao.common.entity.R;
import com.jubao.common.utils.CommonUtils;
import com.jubao.modules.sys.dao.BankMapper;
import com.jubao.modules.sys.entity.BankEntity;
import com.jubao.modules.sys.service.BankService;
import com.jubao.modules.sys.vo.BankVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 资产信息
 * @author jubaodai<363217237@qq.com>
 */
@Service("bankService")
public class BankServiceImpl implements BankService {

	@Autowired
    private BankMapper bankMapper;

    /**
     * 分页查询
     * @param params
     * @return
     */
	@Override
	public Page<BankEntity> listBank(Map<String, Object> params) {
		Query query = new Query(params);
		Page<BankEntity> page = new Page<>(query);
		bankMapper.listForPage(page, query);
		return page;
	}

	@Override
	public Page<BankVo> listChangeBank(Map<String, Object> params) {
		Query query = new Query(params);
		Page<BankVo> page = new Page<>(query);
		bankMapper.listChangeForPage(page,query);
		return page;
	}

    /**
     * 新增
     * @param bank
     * @return
     */
	@Override
	public R saveBank(BankEntity bank) {
		int count = bankMapper.save(bank);
		return CommonUtils.msg(count);
	}

    /**
     * 根据id查询
     * @param id
     * @return
     */
	@Override
	public R getBankById(Long id) {
		BankEntity bank = bankMapper.getObjectById(id);
		return CommonUtils.msg(bank);
	}

    /**
     * 修改
     * @param bank
     * @return
     */
	@Override
	public R updateBank(BankEntity bank) {
		int count = bankMapper.update(bank);
		return CommonUtils.msg(count);
	}

    /**
     * 删除
     * @param id
     * @return
     */
	@Override
	public R batchRemove(Long[] id) {
		int count = bankMapper.batchRemove(id);
		return CommonUtils.msg(id, count);
	}


}
